<?php
class DB {
	private static $objects = array();
	private static $settings = array();
	
	private function __construct() { }
	
	public static function getDB($name) {
		if (isset(self::$objects[$name])) {
			return self::$objects[$name];
		} else if (self::$settings[$name]) {
			self::$objects[$name] = new PDO(self::$settings[$name][0], self::$settings[$name][1], self::$settings[$name][2]);
			return self::$objects[$name];
		} else {
			// error
		}
	}
	
	public static function setDB($name, $dns, $username, $password) {
		self::$settings[$name] = array($dsn, $username, $password);
	}
}
?>